home *** CD-ROM | disk | FTP | other *** search
- /**
- AEFX_SampleM.c
-
- Part of the Adobe After Effects 3.1 SDK
- Copyright (c)1993-96, Adobe Systems Inc, All Rights Reserved.
-
- A simple After Effects plug-in with a custom user interface demonstrating
- the use of PF_Cmd_Event. Matrix and transform operations are performed here.
-
- Revision History
- 1.0, created by dmw
- **/
-
- #include "AEFX_Sample.h"
-
-
- PF_Err SAM_SetIdentityMatrix (PF_FloatMatrix *matrix)
- {
- matrix->mat[0][0] = matrix->mat[1][1] =
- matrix->mat[2][2] = 1;
-
- matrix->mat[0][1] = matrix->mat[0][2] =
- matrix->mat[1][0] = matrix->mat[1][2] =
- matrix->mat[2][0] = matrix->mat[2][1] = 0;
-
- return PF_Err_NONE;
- }
-
-
- PF_Err SAM_ScaleMatrix (
- PF_FloatMatrix *m, /* <> */
- PF_FpLong scaleX, /* >> */
- PF_FpLong scaleY, /* >> */
- PF_FpLong aboutX, /* >> */
- PF_FpLong aboutY ) /* >> */
- {
- PF_FloatMatrix scale;
- PF_Err err = PF_Err_NONE;
-
- if (scaleX != 1.0 || scaleY != 1.0) {
-
- scale.mat[0][0] = scaleX; scale.mat[0][1] = 0; scale.mat[0][2] = 0;
- scale.mat[1][0] = 0; scale.mat[1][1] = scaleY; scale.mat[1][2] = 0;
-
- scale.mat[2][0] = (1.0 - scaleX) * (aboutX);
- scale.mat[2][1] = (1.0 - scaleY) * (aboutY);
- scale.mat[2][2] = 1;
-
- err = SAM_ConcatMatrix(&scale, m);
-
- }
-
- return err;
- }
-
-
- PF_Err SAM_RotateMatrixPlus (
- PF_FloatMatrix *m, /* <> */
- PF_InData *in_data, /* >> */
- PF_FpLong degrees, /* >> */
- PF_FpLong aboutX, /* >> */
- PF_FpLong aboutY ) /* >> */
- {
- PF_FloatMatrix rotate;
- PF_FpLong radians, s, c;
- PF_Err err = PF_Err_NONE;
-
- if (degrees) {
- radians = PF_RAD_PER_DEGREE * degrees;
- s = PF_SIN(radians);
- c = PF_COS(radians);
-
- rotate.mat[0][0] = c; rotate.mat[0][1] = s; rotate.mat[0][2] = 0;
- rotate.mat[1][0] =-s; rotate.mat[1][1] = c; rotate.mat[1][2] = 0;
-
- rotate.mat[2][0] = (aboutX * (1.0 - c) + aboutY * s);
- rotate.mat[2][1] = (aboutY * (1.0 - c) - aboutX * s);
-
- rotate.mat[2][2] = 1;
-
- err = (SAM_ConcatMatrix(&rotate, m));
- }
-
- return err;
- }
-
-
- PF_Err SAM_ConcatMatrix (
- const PF_FloatMatrix *src, /* >> */
- PF_FloatMatrix *dst ) /* <> */
- {
- PF_FloatMatrix tmp;
- register long i, j;
- PF_FpLong temp;
-
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 3; j++) {
- temp = dst->mat[i][0] * src->mat[0][j] +
- dst->mat[i][1] * src->mat[1][j] +
- dst->mat[i][2] * src->mat[2][j];
-
- tmp.mat[i][j] = temp;
-
- }
- }
-
- *dst = tmp;
-
- return PF_Err_NONE;
- }
-
-
- PF_Err SAM_TransformFixPoints (
- const PF_FloatMatrix *m, /* >> */
- long count, /* >> */
- PF_FixedPoint *pts ) /* <> */
- {
- long i;
- PF_FixedPoint temp;
- PF_FpLong d;
- PF_Err err = PF_Err_NONE;
-
- for (i=0; i<count; i++) {
-
- temp = pts[i];
-
- d = temp.x * m->mat[0][0] + temp.y * m->mat[1][0] + 65536.0 * m->mat[2][0];
- pts[i].x = (long)(d);
-
- d = temp.x * m->mat[0][1] + temp.y * m->mat[1][1] + 65536.0 * m->mat[2][1];
- pts[i].y = (long)(d);
- }
-
- return err;
- }
-